package com.bupt.godxian.charging.service;
import com.bupt.godxian.charging.entity.ChargeRequest;
import com.bupt.godxian.charging.mapper.ChargeRequestMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChargeRequestService {
    private final ChargeRequestMapper chargeRequestMapper;

    @Autowired
    public ChargeRequestService(ChargeRequestMapper chargeRequestMapper) {
        this.chargeRequestMapper = chargeRequestMapper;
    }

    public ChargeRequest createChargeRequest(ChargeRequest chargeRequest) {
        // 添加创建充电请求的逻辑
        // 返回创建的充电请求对象
        chargeRequestMapper.insert(chargeRequest);
        return chargeRequest;
    }
    public ChargeRequest getChargeRequestByUserId(Long userId) {
        return chargeRequestMapper.getChargeRequestByUserId(userId);
    }

    public ChargeRequest getUndoChargeRequestByUserId(Long userId) {
        return chargeRequestMapper.getUndoChargeRequestByUserId(userId);
    }
    //获取
    public int getHisFrontCarsCount(String chargeMode) {
        return chargeRequestMapper.getHisFrontCarsCount(chargeMode);
    }
    public List<ChargeRequest> findByChargeModeAndStateNotZero(String chargeMode){
        return chargeRequestMapper.findByChargeModeAndStateNotZero(chargeMode);
    }

    public ChargeRequest getChargeRequestById(Long id) {
        // 添加根据 ID 查询充电请求的逻辑
        // 返回查询到的充电请求对象
        return chargeRequestMapper.selectByPrimaryKey(id);
    }

    // 添加其他需要的方法，如更新充电请求、删除充电请求等

}
